#!/usr/bin/env python

'''
data collapse for T = 0.7
'''
from __future__ import division
import sys
sys.path += ['..']
import common
import os
import math
import matplotlib.pyplot

# tList = [0.60, 0.62, 0.63, 0.64, 0.65, 0.70, 0.80, 0.90, 0.92, 0.95, 0.96, 1.00, 1.05]
Tc = 0.7
b = -0.0620644108592
a = 1.54
path = os.path.join('..', '..', '..', '..', 'results', 'square_clock', 'J_1.0', 'q_6')

lList = common.choice(path)

for tL in lList:
    L = int(tL.replace("L_", ''))
    lPath = os.path.join(path, tL, 'M')  

    tList, mList, err = common.sorted_list(lPath)
    
    x = []
    y = []
    for i, T in enumerate(tList):
        if T > Tc:
            t = (T - Tc) / Tc
            print 
            x += [ 1 / L * math.exp(a * t**(-0.5)) ]
            y += [ mList[i] * L**(b) ]
    
    matplotlib.pyplot.plot(x, y, '*', label = "$L = %i$"%L)

matplotlib.pyplot.xscale('log')
matplotlib.pyplot.legend()
matplotlib.pyplot.show()